﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace STKMIS
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
            frmMain = this;
        }

        private void NowTimer_Tick(object sender, EventArgs e)
        {
            NowDateTime.Text = "当前时间：" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "     " + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek);
        }

        private void FrmMain_Resize(object sender, EventArgs e)
        {
            LoginName.Width = this.Width - this.Width / 2;
            NowDateTime.Width = this.Width / 2;
        }

        private void FrmMain_Load(object sender, EventArgs e)
        {
            //FrmUserLogin loginForm = new FrmUserLogin();
            //DialogResult dialogResult = loginForm.ShowDialog();
            //if (dialogResult != DialogResult.OK)
            //{
            //    Application.Exit();
            //    return;
            //}
            //loginForm.Dispose(); 

            GlobalUserInfo.userID = 1;
            GlobalUserInfo.userName = "超级";
            GlobalUserInfo.loginCode = "Supper";
            GlobalUserInfo.IsSuperUser = true;

            this.dockPanelMain.DockLeftPortion = 180;
            LoginName.Width = this.Width - this.Width / 2;
            NowDateTime.Width = this.Width / 2;
            LoginName.Text = "用户名：" + GlobalUserInfo.loginCode + "       姓名：" + GlobalUserInfo.userName;
            NowDateTime.Text = "当前时间：" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "     " + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek);
            this.NowTimer.Interval = 1000;
            this.NowTimer.Start();

            if (frmLeftMenu == null)
            {
                frmLeftMenu = new FrmLeftMenu();
                frmLeftMenu.Text = "功能菜单";
                frmLeftMenu.Show(this.dockPanelMain, DockState.DockLeft);
            }
            else
            {
                if (frmLeftMenu.IsDisposed)
                {
                    frmLeftMenu = new FrmLeftMenu();
                    frmLeftMenu.Text = "功能菜单";
                    frmLeftMenu.Show(this.dockPanelMain, DockState.DockLeft);
                }
                else
                {
                    frmLeftMenu.Show(this.dockPanelMain, DockState.DockLeft);
                }
            } 
        }
        #region 菜单事件
        private void TSMIPurchaseInStorage_Click(object sender, EventArgs e)
        {
            if (frmPurchaseInStorage == null)
            {
                frmPurchaseInStorage = new FrmPurchaseInStorage();

                frmPurchaseInStorage.Show(this.dockPanelMain, DockState.Document);
            }
            else
            {
                if (frmPurchaseInStorage.IsDisposed)
                {
                    frmPurchaseInStorage = new FrmPurchaseInStorage();

                    frmPurchaseInStorage.Show(this.dockPanelMain, DockState.Document);
                }
                else
                {
                    frmPurchaseInStorage.Focus();
                    //frmUserManage.Show(this.dockPanelMain, DockState.Document);
                }
            } 
        }
        #endregion
        
    }
}
